#!/usr/bin/env bash

include "libs/docker.sh"

#help.cmd docker@image : 构建docker源镜像
#alias.cmd odi : docker@image
dynamic_cmd:docker:image()
{
    if docker:is_image_exist "ohos:latest"; then
        echo "已经存在docker源镜像 (ohos:latest)"
        false || report "构建docker源镜像" || return
    fi

    docker:build
    report "构建docker源镜像"
}

#help.cmd docker@reimage : 重新构建docker源镜像
#alias.cmd odr : docker@reimage
dynamic_cmd:docker:reimage()
{
    docker:build
    report "重新构建docker源镜像"
}

dynamic_cmd:docker:create()
{
    ohos:cd_repo || return
    docker:create $REPO_PATH $CONTAINER_NAME
    report "docker创建"
}

dynamic_cmd:docker:reset()
{
    docker:reset $REPO_PATH $CONTAINER_NAME
}

#help.cmd docker@enter : 进入容器的终端
#alias.cmd ode : docker@enter
dynamic_cmd:docker:enter()
{
    docker:exec "bash"
}
